﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Threading;

namespace YArchitech.Controls.ImgListView
{
	internal class ImageListViewCacheManager : IDisposable
	{
		public bool RetryOnError
		{
			get
			{
				return this.mRetryOnError;
			}
			set
			{
				this.mRetryOnError = value;
			}
		}

		private bool Stopping
		{
			get
			{
				object obj = this.lockObject;
				bool result;
				lock (obj)
				{
					result = this.stopping;
				}
				return result;
			}
		}

		public bool Stopped
		{
			get
			{
				object obj = this.lockObject;
				bool result;
				lock (obj)
				{
					result = this.stopped;
				}
				return result;
			}
		}

		public CacheMode CacheMode
		{
			get
			{
				return this.mCacheMode;
			}
			set
			{
				object obj = this.lockObject;
				lock (obj)
				{
					this.mCacheMode = value;
					if (this.mCacheMode == CacheMode.Continuous)
					{
						this.mCacheLimitAsItemCount = 0;
						this.mCacheLimitAsMemory = 0L;
					}
				}
			}
		}

		public int CacheLimitAsItemCount
		{
			get
			{
				return this.mCacheLimitAsItemCount;
			}
			set
			{
				object obj = this.lockObject;
				lock (obj)
				{
					this.mCacheLimitAsItemCount = value;
					this.mCacheLimitAsMemory = 0L;
					this.mCacheMode = CacheMode.OnDemand;
				}
			}
		}

		public long CacheLimitAsMemory
		{
			get
			{
				return this.mCacheLimitAsMemory;
			}
			set
			{
				object obj = this.lockObject;
				lock (obj)
				{
					this.mCacheLimitAsMemory = value;
					this.mCacheLimitAsItemCount = 0;
					this.mCacheMode = CacheMode.OnDemand;
				}
			}
		}

		public long MemoryUsed
		{
			get
			{
				object obj = this.lockObject;
				long result;
				lock (obj)
				{
					result = this.memoryUsed;
				}
				return result;
			}
		}

		public long CacheSize
		{
			get
			{
				object obj = this.lockObject;
				long result;
				lock (obj)
				{
					result = (long)this.thumbCache.Count;
				}
				return result;
			}
		}

		public ImageListViewCacheManager(ImageListView owner)
		{
			this.lockObject = new object();
			this.mImageListView = owner;
			this.mCacheMode = CacheMode.OnDemand;
			this.mCacheLimitAsItemCount = 0;
			this.mCacheLimitAsMemory = 20971520L;
			this.mRetryOnError = owner.RetryOnError;
			this.toCache = new Stack<ImageListViewCacheManager.CacheItem>();
			this.thumbCache = new Dictionary<Guid, ImageListViewCacheManager.CacheItem>();
			this.editCache = new Dictionary<Guid, Image>();
			this.rendererToCache = new Stack<ImageListViewCacheManager.CacheItem>();
			this.rendererGuid = default(Guid);
			this.rendererItem = null;
			this.memoryUsed = 0L;
			this.memoryUsedByRemoved = 0L;
			this.removedItems = new List<Guid>();
			this.mThread = new Thread(new ThreadStart(this.DoWork));
			this.mThread.IsBackground = true;
			this.stopping = false;
			this.stopped = false;
			this.disposed = false;
			this.mThread.Start();
			while (!this.mThread.IsAlive)
			{
			}
		}

		public void BeginItemEdit(Guid guid, string filename)
		{
			object obj = this.lockObject;
			lock (obj)
			{
				if (!this.editCache.ContainsKey(guid))
				{
					using (Image image = Image.FromFile(filename))
					{
						this.editCache.Add(guid, new Bitmap(image));
					}
				}
			}
		}

		public void BeginItemEdit(Guid guid)
		{
			object obj = this.lockObject;
			lock (obj)
			{
				if (!this.editCache.ContainsKey(guid))
				{
					VirtualItemImageEventArgs virtualItemImageEventArgs = new VirtualItemImageEventArgs(this.mImageListView.Items[guid].mVirtualItemKey);
					this.mImageListView.RetrieveVirtualItemImageInternal(virtualItemImageEventArgs);
					if (!string.IsNullOrEmpty(virtualItemImageEventArgs.FileName))
					{
						this.editCache.Add(guid, Image.FromFile(virtualItemImageEventArgs.FileName));
					}
				}
			}
		}

		public void EndItemEdit(Guid guid)
		{
			object obj = this.lockObject;
			lock (obj)
			{
				if (this.editCache.ContainsKey(guid))
				{
					this.editCache[guid].Dispose();
					this.editCache.Remove(guid);
				}
				if (this.rendererGuid == guid)
				{
					this.rendererGuid = Guid.Empty;
					if (this.rendererItem != null)
					{
						this.rendererItem.Dispose();
					}
				}
			}
		}

		public CacheState GetCacheState(Guid guid)
		{
			object obj = this.lockObject;
			lock (obj)
			{
				ImageListViewCacheManager.CacheItem cacheItem = null;
				if (this.thumbCache.TryGetValue(guid, out cacheItem))
				{
					return cacheItem.State;
				}
			}
			return CacheState.Unknown;
		}

		public void Clear()
		{
			object obj = this.lockObject;
			lock (obj)
			{
				foreach (ImageListViewCacheManager.CacheItem cacheItem in this.thumbCache.Values)
				{
					cacheItem.Dispose();
				}
				this.thumbCache.Clear();
				this.removedItems.Clear();
				this.memoryUsed = 0L;
				this.memoryUsedByRemoved = 0L;
			}
		}

		public void Remove(Guid guid)
		{
			this.Remove(guid, false);
		}

		public void Remove(Guid guid, bool removeNow)
		{
			object obj = this.lockObject;
			lock (obj)
			{
				ImageListViewCacheManager.CacheItem cacheItem = null;
				if (this.thumbCache.TryGetValue(guid, out cacheItem))
				{
					if (removeNow)
					{
						this.memoryUsed -= (long)(cacheItem.Size.Width * cacheItem.Size.Height * 24 / 8);
						cacheItem.Dispose();
						this.thumbCache.Remove(guid);
					}
					else
					{
						this.memoryUsedByRemoved += (long)(cacheItem.Size.Width * cacheItem.Size.Height * 24 / 8);
						this.removedItems.Add(guid);
						if ((this.mCacheLimitAsMemory != 0L && this.memoryUsedByRemoved > this.mCacheLimitAsMemory / 4L) || (this.mCacheLimitAsItemCount != 0 && this.removedItems.Count > this.mCacheLimitAsItemCount / 4))
						{
							ImageListViewCacheManager.CacheItem cacheItem2 = null;
							foreach (Guid key in this.removedItems)
							{
								if (this.thumbCache.TryGetValue(key, out cacheItem2))
								{
									cacheItem2.Dispose();
									this.thumbCache.Remove(key);
								}
							}
							this.removedItems.Clear();
							this.memoryUsed -= this.memoryUsedByRemoved;
							this.memoryUsedByRemoved = 0L;
						}
					}
				}
			}
		}

		public void Add(Guid guid, string filename, Size thumbSize, UseEmbeddedThumbnails useEmbeddedThumbnails)
		{
			object obj = this.lockObject;
			lock (obj)
			{
				ImageListViewCacheManager.CacheItem cacheItem = null;
				if (this.thumbCache.TryGetValue(guid, out cacheItem))
				{
					if (cacheItem.Size == thumbSize && cacheItem.UseEmbeddedThumbnails == useEmbeddedThumbnails)
					{
						return;
					}
					cacheItem.Dispose();
					this.thumbCache.Remove(guid);
				}
				this.toCache.Push(new ImageListViewCacheManager.CacheItem(guid, filename, thumbSize, null, CacheState.Unknown, useEmbeddedThumbnails));
				Monitor.Pulse(this.lockObject);
			}
		}

		public void Add(Guid guid, object key, Size thumbSize, UseEmbeddedThumbnails useEmbeddedThumbnails)
		{
			object obj = this.lockObject;
			lock (obj)
			{
				ImageListViewCacheManager.CacheItem cacheItem = null;
				if (this.thumbCache.TryGetValue(guid, out cacheItem))
				{
					if (cacheItem.Size == thumbSize && cacheItem.UseEmbeddedThumbnails == useEmbeddedThumbnails)
					{
						return;
					}
					cacheItem.Dispose();
					this.thumbCache.Remove(guid);
				}
				this.toCache.Push(new ImageListViewCacheManager.CacheItem(guid, key, thumbSize, null, CacheState.Unknown, useEmbeddedThumbnails));
				Monitor.Pulse(this.lockObject);
			}
		}

		public void Add(Guid guid, object key, Size thumbSize, Image thumb, UseEmbeddedThumbnails useEmbeddedThumbnails)
		{
			object obj = this.lockObject;
			lock (obj)
			{
				ImageListViewCacheManager.CacheItem cacheItem = null;
				if (this.thumbCache.TryGetValue(guid, out cacheItem))
				{
					if (cacheItem.Size == thumbSize && cacheItem.UseEmbeddedThumbnails == useEmbeddedThumbnails)
					{
						return;
					}
					cacheItem.Dispose();
					this.thumbCache.Remove(guid);
				}
				this.thumbCache.Add(guid, new ImageListViewCacheManager.CacheItem(guid, key, thumbSize, thumb, CacheState.Cached, useEmbeddedThumbnails));
			}
			try
			{
				if (this.mImageListView != null && this.mImageListView.IsHandleCreated && !this.mImageListView.IsDisposed)
				{
					this.mImageListView.Invoke(new ThumbnailCachedEventHandlerInternal(this.mImageListView.OnThumbnailCachedInternal), new object[]
					{
						guid,
						false
					});
					this.mImageListView.Invoke(new RefreshDelegateInternal(this.mImageListView.OnRefreshInternal));
				}
			}
			catch (ObjectDisposedException)
			{
				if (!this.Stopping)
				{
					throw;
				}
			}
			catch (Autodesk.Revit.Exceptions.InvalidOperationException)
			{
				if (!this.Stopping)
				{
					throw;
				}
			}
		}

		public void AddToRendererCache(Guid guid, string filename, Size thumbSize, UseEmbeddedThumbnails useEmbeddedThumbnails)
		{
			object obj = this.lockObject;
			lock (obj)
			{
				if (!(this.rendererGuid == guid) || this.rendererItem == null || !(this.rendererItem.Size == thumbSize) || this.rendererItem.UseEmbeddedThumbnails != useEmbeddedThumbnails)
				{
					this.rendererToCache.Clear();
					this.rendererToCache.Push(new ImageListViewCacheManager.CacheItem(guid, filename, thumbSize, null, CacheState.Unknown, useEmbeddedThumbnails));
					Monitor.Pulse(this.lockObject);
				}
			}
		}

		public void AddToRendererCache(Guid guid, object key, Size thumbSize, UseEmbeddedThumbnails useEmbeddedThumbnails)
		{
			object obj = this.lockObject;
			lock (obj)
			{
				if (!(this.rendererGuid == guid) || this.rendererItem == null || !(this.rendererItem.Size == thumbSize) || this.rendererItem.UseEmbeddedThumbnails != useEmbeddedThumbnails)
				{
					this.rendererToCache.Clear();
					this.rendererToCache.Push(new ImageListViewCacheManager.CacheItem(guid, key, thumbSize, null, CacheState.Unknown, useEmbeddedThumbnails));
					Monitor.Pulse(this.lockObject);
				}
			}
		}

		public Image GetRendererImage(Guid guid, Size thumbSize, UseEmbeddedThumbnails useEmbeddedThumbnails)
		{
			object obj = this.lockObject;
			lock (obj)
			{
				if (this.rendererGuid == guid && this.rendererItem != null && this.rendererItem.Size == thumbSize && this.rendererItem.UseEmbeddedThumbnails == useEmbeddedThumbnails)
				{
					return this.rendererItem.Image;
				}
			}
			return null;
		}

		public Image GetImage(Guid guid)
		{
			object obj = this.lockObject;
			lock (obj)
			{
				ImageListViewCacheManager.CacheItem cacheItem = null;
				if (this.thumbCache.TryGetValue(guid, out cacheItem))
				{
					return cacheItem.Image;
				}
			}
			return null;
		}

		public void Stop()
		{
			object obj = this.lockObject;
			lock (obj)
			{
				if (!this.stopping)
				{
					this.stopping = true;
					Monitor.Pulse(this.lockObject);
				}
			}
		}

		public void Dispose()
		{
			if (!this.disposed)
			{
				object obj = this.lockObject;
				lock (obj)
				{
					foreach (ImageListViewCacheManager.CacheItem cacheItem in this.thumbCache.Values)
					{
						cacheItem.Dispose();
					}
					this.thumbCache.Clear();
					foreach (ImageListViewCacheManager.CacheItem cacheItem2 in this.toCache)
					{
						cacheItem2.Dispose();
					}
					this.toCache.Clear();
					foreach (Image image in this.editCache.Values)
					{
						image.Dispose();
					}
					this.editCache.Clear();
					foreach (ImageListViewCacheManager.CacheItem cacheItem3 in this.rendererToCache)
					{
						cacheItem3.Dispose();
					}
					this.rendererToCache.Clear();
					if (this.rendererItem != null)
					{
						this.rendererItem.Dispose();
					}
					this.memoryUsed = 0L;
					this.memoryUsedByRemoved = 0L;
					this.removedItems.Clear();
				}
				this.disposed = true;
			}
		}

		private void DoWork()
		{
			Stopwatch stopwatch = new Stopwatch();
			object obj;
			while (!this.Stopping)
			{
				Guid guid = default(Guid);
				ImageListViewCacheManager.CacheItem cacheItem = null;
				bool flag = false;
				obj = this.lockObject;
				lock (obj)
				{
					if (this.toCache.Count == 0 && this.rendererToCache.Count == 0)
					{
						Monitor.Wait(this.lockObject);
					}
				}
				bool flag3 = false;
				bool flag4 = false;
				bool flag5 = true;
				while (flag5 && !this.Stopping)
				{
					obj = this.lockObject;
					lock (obj)
					{
						stopwatch.Start();
						if (this.toCache.Count != 0)
						{
							cacheItem = this.toCache.Pop();
							guid = cacheItem.Guid;
							ImageListViewCacheManager.CacheItem cacheItem2 = null;
							if (this.thumbCache.TryGetValue(guid, out cacheItem2))
							{
								if (cacheItem2.Size == cacheItem.Size)
								{
									cacheItem = null;
								}
								else
								{
									this.thumbCache.Remove(guid);
								}
							}
						}
						else if (this.rendererToCache.Count != 0)
						{
							cacheItem = this.rendererToCache.Pop();
							guid = cacheItem.Guid;
							this.rendererToCache.Clear();
							flag = true;
						}
					}
					bool flag6 = true;
					if (cacheItem != null && this.mCacheMode == CacheMode.OnDemand)
					{
						try
						{
							if (this.mImageListView != null && this.mImageListView.IsHandleCreated && !this.mImageListView.IsDisposed)
							{
								flag6 = (bool)this.mImageListView.Invoke(new CheckItemVisibleDelegateInternal(this.mImageListView.IsItemVisible), new object[]
								{
									guid
								});
							}
						}
						catch (ObjectDisposedException)
						{
							if (!this.Stopping)
							{
								throw;
							}
						}
						catch (Autodesk.Revit.Exceptions.InvalidOperationException)
						{
							if (!this.Stopping)
							{
								throw;
							}
						}
					}
					obj = this.lockObject;
					lock (obj)
					{
						if (!flag && !flag6)
						{
							cacheItem = null;
						}
					}
					ImageListViewCacheManager.CacheItem cacheItem3 = null;
					if (cacheItem != null)
					{
						Image image = null;
						Image image2 = null;
						obj = this.lockObject;
						lock (obj)
						{
							if (!this.editCache.TryGetValue(guid, out image2))
							{
								image2 = null;
							}
						}
						if (image2 != null)
						{
							image = Utility.ThumbnailFromImage(image2, cacheItem.Size, Color.White);
						}
						if (image == null)
						{
							if (cacheItem.IsVirtualItem)
							{
								VirtualItemThumbnailEventArgs virtualItemThumbnailEventArgs = new VirtualItemThumbnailEventArgs(cacheItem.VirtualItemKey, cacheItem.Size);
								if (this.mImageListView != null && this.mImageListView.IsHandleCreated && !this.mImageListView.IsDisposed)
								{
									this.mImageListView.RetrieveVirtualItemThumbnailInternal(virtualItemThumbnailEventArgs);
								}
								if (virtualItemThumbnailEventArgs.ThumbnailImage != null)
								{
									image = virtualItemThumbnailEventArgs.ThumbnailImage;
								}
							}
							else
							{
								image = Utility.ThumbnailFromFile(cacheItem.FileName, cacheItem.Size, cacheItem.UseEmbeddedThumbnails, Color.White);
							}
						}
						if (image == null)
						{
							if (!this.mRetryOnError)
							{
								cacheItem3 = new ImageListViewCacheManager.CacheItem(guid, cacheItem.FileName, cacheItem.Size, null, CacheState.Error, cacheItem.UseEmbeddedThumbnails);
							}
							else
							{
								cacheItem3 = null;
							}
						}
						else
						{
							cacheItem3 = new ImageListViewCacheManager.CacheItem(guid, cacheItem.FileName, cacheItem.Size, image, CacheState.Cached, cacheItem.UseEmbeddedThumbnails);
							flag4 = true;
						}
						if (cacheItem3 != null)
						{
							if (flag)
							{
								obj = this.lockObject;
								lock (obj)
								{
									if (this.rendererItem != null)
									{
										this.rendererItem.Dispose();
									}
									this.rendererGuid = guid;
									this.rendererItem = cacheItem3;
									flag = false;
									goto IL_3DA;
								}
							}
							obj = this.lockObject;
							lock (obj)
							{
								this.thumbCache.Remove(guid);
								this.thumbCache.Add(guid, cacheItem3);
								if (image != null)
								{
									this.memoryUsed += (long)(image.Width * image.Height * 24 / 8);
									if ((this.mCacheLimitAsMemory != 0L && this.memoryUsed > this.mCacheLimitAsMemory) || (this.mCacheLimitAsItemCount != 0 && this.thumbCache.Count > this.mCacheLimitAsItemCount))
									{
										flag3 = true;
									}
								}
							}
						}
						IL_3DA:
						try
						{
							if (this.mImageListView != null && this.mImageListView.IsHandleCreated && !this.mImageListView.IsDisposed)
							{
								this.mImageListView.Invoke(new ThumbnailCachedEventHandlerInternal(this.mImageListView.OnThumbnailCachedInternal), new object[]
								{
									guid,
									cacheItem3 == null
								});
							}
						}
						catch (ObjectDisposedException)
						{
							if (!this.Stopping)
							{
								throw;
							}
						}
						catch (Autodesk.Revit.Exceptions.InvalidOperationException)
						{
							if (!this.Stopping)
							{
								throw;
							}
						}
					}
					obj = this.lockObject;
					lock (obj)
					{
						if (this.toCache.Count == 0 && this.rendererToCache.Count == 0)
						{
							flag5 = false;
						}
					}
					stopwatch.Stop();
					if (stopwatch.ElapsedMilliseconds > 100L)
					{
						try
						{
							if (this.mImageListView != null && this.mImageListView.IsHandleCreated && !this.mImageListView.IsDisposed)
							{
								this.mImageListView.Invoke(new RefreshDelegateInternal(this.mImageListView.OnRefreshInternal));
							}
							stopwatch.Reset();
						}
						catch (ObjectDisposedException)
						{
							if (!this.Stopping)
							{
								throw;
							}
						}
						catch (Autodesk.Revit.Exceptions.InvalidOperationException)
						{
							if (!this.Stopping)
							{
								throw;
							}
						}
					}
					if (flag5)
					{
						stopwatch.Start();
					}
					else
					{
						stopwatch.Reset();
						stopwatch.Stop();
					}
				}
				if (flag3)
				{
					Dictionary<Guid, bool> dictionary = new Dictionary<Guid, bool>();
					try
					{
						if (this.mImageListView != null && this.mImageListView.IsHandleCreated && !this.mImageListView.IsDisposed)
						{
							dictionary = (Dictionary<Guid, bool>)this.mImageListView.Invoke(new GetVisibleItemsDelegateInternal(this.mImageListView.GetVisibleItems));
						}
					}
					catch (ObjectDisposedException)
					{
						if (!this.Stopping)
						{
							throw;
						}
					}
					catch (Autodesk.Revit.Exceptions.InvalidOperationException)
					{
						if (!this.Stopping)
						{
							throw;
						}
					}
					if (dictionary.Count != 0)
					{
						obj = this.lockObject;
						lock (obj)
						{
							foreach (KeyValuePair<Guid, ImageListViewCacheManager.CacheItem> keyValuePair in this.thumbCache)
							{
								if (!dictionary.ContainsKey(keyValuePair.Key) && keyValuePair.Value.State == CacheState.Cached && keyValuePair.Value.Image != null)
								{
									this.removedItems.Add(keyValuePair.Key);
									this.memoryUsedByRemoved += (long)(keyValuePair.Value.Image.Width * keyValuePair.Value.Image.Width * 24 / 8);
								}
							}
							foreach (Guid key in this.removedItems)
							{
								if (this.thumbCache.ContainsKey(key))
								{
									this.thumbCache[key].Dispose();
									this.thumbCache.Remove(key);
								}
							}
							this.removedItems.Clear();
							this.memoryUsed -= this.memoryUsedByRemoved;
							this.memoryUsedByRemoved = 0L;
						}
					}
				}
				if (flag4)
				{
					try
					{
						if (this.mImageListView != null && this.mImageListView.IsHandleCreated && !this.mImageListView.IsDisposed)
						{
							this.mImageListView.Invoke(new RefreshDelegateInternal(this.mImageListView.OnRefreshInternal));
						}
					}
					catch (ObjectDisposedException)
					{
						if (!this.Stopping)
						{
							throw;
						}
					}
					catch (Autodesk.Revit.Exceptions.InvalidOperationException)
					{
						if (!this.Stopping)
						{
							throw;
						}
					}
				}
			}
			obj = this.lockObject;
			lock (obj)
			{
				this.stopped = true;
			}
		}

		private readonly object lockObject;

		private ImageListView mImageListView;

		private Thread mThread;

		private CacheMode mCacheMode;

		private int mCacheLimitAsItemCount;

		private long mCacheLimitAsMemory;

		private bool mRetryOnError;

		private Stack<ImageListViewCacheManager.CacheItem> toCache;

		private Dictionary<Guid, ImageListViewCacheManager.CacheItem> thumbCache;

		private Dictionary<Guid, Image> editCache;

		private Stack<ImageListViewCacheManager.CacheItem> rendererToCache;

		private Guid rendererGuid;

		private ImageListViewCacheManager.CacheItem rendererItem;

		private long memoryUsed;

		private long memoryUsedByRemoved;

		private List<Guid> removedItems;

		private bool stopping;

		private bool stopped;

		private bool disposed;

		private class CacheItem : IDisposable
		{
			public Guid Guid
			{
				get
				{
					return this.mGuid;
				}
			}

			public string FileName
			{
				get
				{
					return this.mFileName;
				}
			}

			public Size Size
			{
				get
				{
					return this.mSize;
				}
			}

			public Image Image
			{
				get
				{
					return this.mImage;
				}
			}

			public CacheState State
			{
				get
				{
					return this.mState;
				}
			}

			public UseEmbeddedThumbnails UseEmbeddedThumbnails
			{
				get
				{
					return this.mUseEmbeddedThumbnails;
				}
			}

			public bool IsVirtualItem
			{
				get
				{
					return this.mIsVirtualItem;
				}
			}

			public object VirtualItemKey
			{
				get
				{
					return this.mVirtualItemKey;
				}
			}

			public CacheItem(Guid guid, object key, Size size, Image image, CacheState state) : this(guid, key, size, image, state, UseEmbeddedThumbnails.Auto)
			{
			}

			public CacheItem(Guid guid, object key, Size size, Image image, CacheState state, UseEmbeddedThumbnails useEmbeddedThumbnails)
			{
				this.mGuid = guid;
				this.mVirtualItemKey = key;
				this.mFileName = string.Empty;
				this.mSize = size;
				this.mImage = image;
				this.mState = state;
				this.mUseEmbeddedThumbnails = useEmbeddedThumbnails;
				this.mIsVirtualItem = true;
				this.disposed = false;
			}

			public CacheItem(Guid guid, string filename, Size size, Image image, CacheState state) : this(guid, filename, size, image, state, UseEmbeddedThumbnails.Auto)
			{
			}

			public CacheItem(Guid guid, string filename, Size size, Image image, CacheState state, UseEmbeddedThumbnails useEmbeddedThumbnails)
			{
				this.mGuid = guid;
				this.mFileName = filename;
				this.mSize = size;
				this.mImage = image;
				this.mState = state;
				this.mUseEmbeddedThumbnails = useEmbeddedThumbnails;
				this.mIsVirtualItem = false;
				this.disposed = false;
			}

			public void Dispose()
			{
				if (!this.disposed)
				{
					if (this.mImage != null)
					{
						this.mImage.Dispose();
						this.mImage = null;
					}
					this.disposed = true;
				}
			}

			private Guid mGuid;

			private string mFileName;

			private Size mSize;

			private Image mImage;

			private CacheState mState;

			private UseEmbeddedThumbnails mUseEmbeddedThumbnails;

			private bool mIsVirtualItem;

			private bool disposed;

			private object mVirtualItemKey;
		}
	}
}
